package com.young.nyd.service.impl;

import com.young.common.util.CommonUtil;
import com.young.common.core.dal.service.IDataAccessService;
import com.young.common.util.Page;
import com.young.nyd.model.UviGovernrepairplan;
import com.young.nyd.service.IUviGovernrepairplanService;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.List;

/**
* 治理修复方案表服务实现
* Created by hu on 2018-11-7.
*/
@Service("uviGovernrepairplanService")
public class UviGovernrepairplanServiceImpl implements IUviGovernrepairplanService {

    @Resource(name = "dataAccessService")
    IDataAccessService dataAccessService;//数据层服务

    private static final Logger logger = LoggerFactory.getLogger(UviGovernrepairplanServiceImpl.class);

    private static final String MAPPER = "com.young.nyd.mapper.uviGovernrepairplan";//mapper的namespace

    //获取数据列表
    @Override
    public List<UviGovernrepairplan> getList(UviGovernrepairplan obj) {
        return dataAccessService.getList(MAPPER + ".getList", obj);
    }

    //获取数据列表(分页)
    @Override
    public List<UviGovernrepairplan> getPage(UviGovernrepairplan obj, Page page) {
        return dataAccessService.getList(MAPPER + ".getList", obj, page);
    }

    //查询单条
    @Override
    public UviGovernrepairplan get(String id) {
        return dataAccessService.getObject(MAPPER + ".get", id);
    }

    //统计数量
    @Override
    public int count(UviGovernrepairplan obj) {
        return dataAccessService.getObject(MAPPER + ".count", obj);
    }

    //修改
    @Override
    public int update(UviGovernrepairplan obj) {
        return dataAccessService.update(MAPPER + ".update", obj);
    }

    //批量删除
    @Override
    public int delete(String[] idArr) {
        int i = 0;
        for(String id : idArr){
            i += this.delete(id);
        }
        return i;
    }

    //删除单条
    @Override
    public int delete(String id) {
        return dataAccessService.delete(MAPPER + ".delete", id);
    }

    //插入
    @Override
    public int insert(UviGovernrepairplan obj) {
        obj.setId(CommonUtil.getUUID());
        return dataAccessService.insert(MAPPER + ".insert", obj);
    }

    //批量插入
    @Override
    public int batchInsert(List<UviGovernrepairplan> list) {
        int i = 0;
        for(UviGovernrepairplan item : list){
            i += this.insert(item);
        }
        return i;
    }

    //查询最大序号
    @Override
    public String maxSerialnumber(UviGovernrepairplan obj) throws Exception {
        String max = dataAccessService.getObject(MAPPER + ".maxSerialnumber",obj);
        return max;
    }

}